package com.tjetc.vo;

import com.tjetc.constant.CodeConstant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @author tjetc
 * @Date 2025/6/4 下午4:46
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Builder
public class Result {
    private int code;
    private String msg;
    private Object data;

    public static Result ok() {
        return new Result().setCode(CodeConstant.SUCCESS).setMsg("操作成功");
    }
    public static Result ok(Object data){
        return new Result().setCode(CodeConstant.SUCCESS).setMsg("操作成功").setData(data);
    }
    public static Result fail() {
        return new Result().setCode(CodeConstant.FAIL).setMsg("操作失败");
    }
    public static Result fail(String msg){
        return new Result().setCode(CodeConstant.FAIL).setMsg(msg);
    }
    public static Result submit(Object data) {
        return new Result().setCode(CodeConstant.SUBMIT).setData(data);
    }
    public static Result code(Integer code){
        return new Result().setCode(code);
    }
}
